package Context;
use strict;
use JSON;

sub new
{
	my $class = shift;
	
	return bless { 
		dict => { @_ , base_host => $ENV{BASE_HOST}},
		onlydict => { @_ },
	}, $class;	
}

sub add_ifnotexists
{
	my $self = shift;
	my ($k, $v) = @_;
	
	if($k && !defined $self->{dict}{$k} && $v){
		$self->{dict}{$k} = $v;
	}	
}

sub as_json
{
	my $self = shift;
	
	return to_json($self->{onlydict});	
}

sub as_hash
{
	my $self = shift;
	
	return 	$self->{onlydict};
}

sub as_array
{
	my $self = shift;
	
	return 	( %{ $self->{onlydict} } );
}
1;